/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.CreateDistributionListRequest;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateDistributionList
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 43 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 51 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 58 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 59 */     Provisioning prov = Provisioning.getInstance();
/* 60 */     CreateDistributionListRequest req = (CreateDistributionListRequest)JaxbUtil.elementToJaxb(request);
/*    */     
/* 62 */     String name = req.getName().toLowerCase();
/* 63 */     Map<String, Object> attrs = req.getAttrsAsOldMultimap(true);
/*    */     
/* 65 */     boolean dynamic = Boolean.TRUE.equals(req.getDynamic());
/*    */     
/* 67 */     if (dynamic) {
/* 68 */       checkDomainRightByEmail(zsc, name, Rights.Admin.R_createGroup);
/* 69 */       checkSetAttrsOnCreate(zsc, TargetType.group, name, attrs);
/*    */     } else {
/* 71 */       checkDomainRightByEmail(zsc, name, Rights.Admin.R_createDistributionList);
/* 72 */       checkSetAttrsOnCreate(zsc, TargetType.dl, name, attrs);
/*    */     }
/*    */     
/* 75 */     Group group = prov.createGroup(name, attrs, dynamic);
/*    */     
/* 77 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateDistributionList", "name", name }, attrs));
/*    */     
/*    */ 
/* 80 */     Element response = zsc.createElement(AdminConstants.CREATE_DISTRIBUTION_LIST_RESPONSE);
/*    */     
/* 82 */     GetDistributionList.encodeDistributionList(response, group);
/*    */     
/* 84 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 89 */     relatedRights.add(Rights.Admin.R_createDistributionList);
/* 90 */     relatedRights.add(Rights.Admin.R_createGroup);
/* 91 */     notes.add(String.format("All attrs provided in the attribute list have to settable by. the authed admin.   You can grant the %s right, which allows setting all attributes on %s, or grant the set attrs right just for the attributes the admin needs to set while creating an entry.", new Object[] { Rights.Admin.R_modifyDistributionList.getName(), "distribution list" }));
/*    */     
/* 93 */     notes.add(String.format("All attrs provided in the attribute list have to settable by. the authed admin.   You can grant the %s right, which allows setting all attributes on %s, or grant the set attrs right just for the attributes the admin needs to set while creating an entry.", new Object[] { Rights.Admin.R_modifyGroup.getName(), "group" }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CreateDistributionList.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */